package com.pmcc.core.web;

import com.pmcc.core.entity.Dict;
import com.pmcc.core.service.DictService;
import com.pmcc.utils.AntdPage;
import com.pmcc.utils.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * 字典管理
 * Created by chenqf on 2017/8/18.
 */
@RestController()
@RequestMapping("api/v1/dict")
public class DictController {
    @Autowired
    DictService dictService;

    @GetMapping(value="queryByPage")
    public ResultBean queryByPage(AntdPage antdPage, Dict dict) {
        return dictService.queryByPage(antdPage,dict);
    }

    @PostMapping("addDict")
    public ResultBean addDict(@RequestBody Dict dict) {
        return dictService.addDict(dict);
    }
    @GetMapping("queryById")
    public ResultBean queryById(String id) {
        return dictService.queryById(id);
    }
    @PostMapping(value ="edit")
    public ResultBean editDict(@RequestBody Map map) {
        return dictService.editDict(map);
    }
    @GetMapping(value ="deleteDict")
    public ResultBean deleteDict(String id) {
        return dictService.deleteDict(id);
    }
    /**
     * 校验code值是否重复
     */
    @GetMapping(value ="queryCode")
    public ResultBean queryCode(String code) {
        return dictService.queryCode(code);
    }
}
